<?php
$menu = 3;
$title = '학생 수업정보';
$g4_path = "../"; 
require_once ($g4_path.'common.php');
require_once ('./admin.head.php');
require_once ('./admin.lib.php');

if(!isset($_GET['mb_no'])) {
    alert('잘못된 접근입니다');
}
extract($_GET);

$sql = "SELECT count(1) from course_order WHERE student = $mb_no";
$page = isset($_GET['page'])? $_GET['page']: 1;
list($totalCount) = mysql_fetch_array(mysql_query($sql));

$count = $totalCount - ($page - 1) * 20;
$sql = "SELECT mb_no, mb_name, mb_tel, mb_hp FROM g4_member g WHERE g.mb_no = '$mb_no'";
$itemData = mysql_fetch_assoc(mysql_query($sql));
$sql = "SELECT count(1) from course_order c WHERE student = $mb_no";
list($itemData['courseCount']) =  mysql_fetch_array(mysql_query($sql));
$sql = "SELECT w_mon+w_tue+w_wed+w_thu+w_fri+w_sat from course c, course_order o WHERE o.student = {$mb_no} AND c.no = o.course";
list($itemData['week']) = mysql_fetch_array(mysql_query($sql));
if(!$itemData['week']) $itemData['week'] = 0;
$itemData['month'] = $itemData['week'] * 4;

$limitSQL = getLimit();
$dataSQL = "SELECT c.name as coursename, c.code as coursecode, c.starttime as starttime, b.name as bookname, c.no as courseno, c.perlimit FROM course_order o, course c, book b WHERE o.student = $mb_no AND o.course = c.no AND c.bookcode = b.no $limitSQL";
$countSQL = "SELECT count(*) from course_order where student = $mb_no";
list($totalCount) = mysql_fetch_array(mysql_query($countSQL));
$res = mysql_query($dataSQL);

$data = array();
while($temp = mysql_fetch_assoc($res)) {
        $sql = "SELECT count(1) FROM course_order WHERE  course = {$temp['courseno']}";
        list($temp['studentCount']) = mysql_fetch_array(mysql_query($sql));
        $temp['count'] = $count--;
        $temp['starttime'] = $temp['starttime']++.'시~'.$temp['starttime'].'시';
    $data[] = $temp;
}

$pager = getPager($totalCount);
echo mysql_error();
$tpl->define('basic',"studentCourseDetail.html");
$tpl->print_('basic');
require_once ('./admin.foot.php');
